package mm.chenchen.modules.file.controller;

import java.util.Map;

import mm.chenchen.modules.file.entity.FileInfoEntity;
import mm.chenchen.modules.file.service.FileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import mm.chenchen.common.utils.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author WangChenChen
 * @email 564697100@qq.com
 * @date 2020-11-13 09:35:28
 */
@RestController
@Api("FileInfo")
@RequestMapping("app/fileinfo")
@CrossOrigin
public class FileInfoController {
    @Autowired
    private FileInfoService service;

    /**
     * 列表
     */
    @ApiOperation(value = "分页检索", notes = "")
    @RequestMapping("/list")
    //@RequiresPermissions("app:fileinfo:list")
    public R findAll(@RequestParam Map<String, Object> params){
        return service.findAll();
    }


    /**
     * 信息
     */
    @ApiOperation(value = "单个检索 ", notes = "")
    @GetMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("app:fileinfo:info")
    public R info(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        return service.findById(objId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "新增", notes = "")
    @PostMapping(value = "", produces = "application/json")
    //@RequiresPermissions("app:fileinfo:save")
    public R save(@RequestBody FileInfoEntity param){
        return service.save(param);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "更新", notes = "")
    @PutMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("app:fileinfo:update")
    public R update(@ApiParam(name = "objId", value = "") @PathVariable Long objId,@RequestBody FileInfoEntity param){
        param.setId(objId);
        return service.update(param);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除", notes = "")
    @DeleteMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("app:fileinfo:delete")
    public R delete(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        //System.out.println(objId+"=================");
        return service.deleteById(objId);
    }

}
